/*
 * File:   Step.h
 * Author: jcrada
 *
 * Created on 28 April 2011, 3:52 PM
 */

#ifndef ECB_STEP_H
#define	ECB_STEP_H

#include "ecb/base/Problem.h"

namespace ecb {

    /* Source: (with Random Gaussian noise)
     * @phdthesis{bf:dejong,
        author = {De Jong, Kenneth Alan},
        title = {An analysis of the behavior of a class of genetic adaptive systems.},
        year = {1975},
        publisher = {University of Michigan},
        school={},
        address = {Ann Arbor, MI, USA}}
     */
    class Step : public Problem {
    public:
        Step(const std::string& id = "Step", const std::string& name = "Step",
                int dimensions = 0, scalar minimum = -5.12, scalar maximum = 5.12,
                bool minimization = true) :
                Problem(id, name, dimensions, minimum, maximum, minimization){}

        scalar f(const std::vector<scalar>& x) {
            scalar result = 0;
            for (size_t i = 0; i < x.size(); ++i) {
                result += std::floor(x[i]);
            }
            return result;
        }
    };
}

#endif	/* ECB_STEP_H */

